<template>
      <sky-chart class="chart" cid="chart" ref="childMethod" :options="options"></sky-chart>
</template>

<script>
import charts from "@/components/base/charts"
import axios from "axios"
// 按需引入，加快加载速度
var echarts = require("echarts/lib/echarts")
var bmap = require("echarts/extension/bmap/bmap")
let series = []
let dataOfLegend = []
let index = 0
export default {
  data() {
    return {
      chart: "chart",
      options:{
            title: {
                text: '地震趋势分析',
                left: 'center'
            },
            legend: {
              data: dataOfLegend,
              type: 'scroll',
              orient: 'vertical',
              right: -5
            },
            tooltip: {
              trigger: 'axis',
              axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                  type : 'line'          // 默认为直线，可选为：'line' | 'shadow'
              }
            },
            xAxis: {
                data: ["三级以上","四级以上","五级以上","六级以上","七级以上","八级以上"],
                axisTick: {
                  alignWithLabel: true
              }
            },
            yAxis: {},
            series: series
      }
    }
  },
  components: {
    "sky-chart": charts
  },
  mounted () {
  },
  methods: {
    addChart: function(yearFromChild,eqdataFromChild) {
      var newSeries = {
        name: yearFromChild+'年',
        type: 'line',
        data: eqdataFromChild
      }
      if(index < 5)
      {
        dataOfLegend.push(newSeries.name)
        series.push(newSeries)
        index++
      }
      else
      {
        alert('不能超过五年！')
      }
    },
    chartClear: function () {
      dataOfLegend.splice(0,dataOfLegend.length)
      series.splice(0,series.length)
      index = 0
    }
  },
  created () {
  }
}
</script>

<style>

</style>
